<!--集包记录-->
<template>
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" pageOption />
    <ex_super_table_page v-bind="option" ref="SuperTablePage" @selection-change="e => selection = e">
    </ex_super_table_page>
  </div>
</template>

<script>
import business_function from '@/common/business_function';
import superTablePageFunction from '@/mixin/super-table-page-function';
import page_table_model_manage from '@/mixin/page_table_model_manage';
import router_params from '@/mixin/router_params';

export default {
  title: "title_second_sort_record",
  mixins: [superTablePageFunction, router_params, page_table_model_manage],
  components: {  },
  data() {
    return {
      isConfirm_routeParamsChange: false,
      selection: [],
      option: {
        search: {
          model: [

            { label: "label_track_code", key: "trackNumber", },
            { label: "label_customer", key: "customerId", type: "common_customer_choose" },
            { label: "label_pms_supply", key: "supplierName", },
            {
              label: "label_operate_user", key: "operatorUser",
            },
            { label: "label_sku", key: "skuId", type: "sku_selec_input" },
            {
              key: 'status', label: 'label_status', type: "select", enum: "PickingWallRecordEnum",
            },
            {
              label: "label_create_time", key: "startTime", type: 'date-picker', attrs: { type: 'datetime' },
              render: (h, { data, item }) => {
                const limitKey = 'endTime'; const limitValue = data[limitKey]; const value = data[item.key];
                return (<ex_super_input value={value} onInput={e => this.$set(data, item.key, e)} type="date-picker" placeholder="label_start_time"
                  attrs={{ type: 'datetime' }} pickerOptions={{ disabledDate: date => { return limitValue ? (limitValue < date.getTime()) : false } }}
                />)
              }
            },
            {
              label: "~", key: "endTime", type: 'date-picker', attrs: { type: 'datetime' },
              render: (h, { data, item }) => {
                const limitKey = 'startTime'; const limitValue = data[limitKey]; const value = data[item.key];
                return (<ex_super_input value={value} onInput={e => this.$set(data, item.key, e)} type="date-picker" placeholder="label_end_time"
                  attrs={{ type: 'datetime', 'default-time': '23:59:59'  }} pickerOptions={{ disabledDate: date => { return limitValue ? (limitValue > date.getTime()) : false } }}
                />)
              }
            },
          ],
        },
        actionExtra: [
          { label: 'label_export', attrs: { type: "primary" }, click: this.exportExcel },
        ],
        table: {
          url: "/wms-api/outbound/OutboundPickingTruckWallRecordRpc/selectListPage.json",
          model: this.init_table_model(),
        },

      },


    };
  },



  methods: {

    option_table_model() {
      return [
        {
          type: 'expandDesc', 'width': 100,
          expandDesc: {
            ...this.$defaultDescAttrs,
            model: [],
          },
        },
        { key: 'orderNo', label: 'label_order_code', 'width': 140, 'show-overflow-tooltip': true, },
        { key: 'pickingTruckNo', label: 'label_pick_car_code', 'width': 140, 'show-overflow-tooltip': true, },

        { key: 'wallCode', label: 'label_distribution_wall_code', 'min-width': 140, 'show-overflow-tooltip': true, },
        { key: 'containerCode', label: 'label_container_no', 'width': 140, 'show-overflow-tooltip': true, },
        {
          key: 'status', label: 'label_status', 'width': 140, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$enumShow(v, "PickingWallRecordEnum")
        },
        {
          key: 'customerName', label: 'label_customer_info', 'width': 130, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$formatNameCode(v, r.customerCode)
        },
        {
          key: 'trackNumber', label: 'label_face_track_code', 'width': 130, 'show-overflow-tooltip': true,
        },

        { key: 'supplierName', label: 'label_pms_supply', 'width': 140, 'show-overflow-tooltip': true, },
        { key: 'skuCount', label: 'label_inner_piece_count', 'width': 140, 'show-overflow-tooltip': true, },
        { key: 'skuOnlyCodes', label: 'label_sku_only_code', 'width': 140, 'show-overflow-tooltip': true, },


        { key: 'creator', label: 'label_operate_user', 'width': 100, 'show-overflow-tooltip': true, },
        { key: 'gmtCreate', label: 'label_create_time', 'width': 130, formatter: (r, c, v, i) => this.$dateFormat(v) },
        {
          type: 'operate', width: 180, fixed: 'right', operate: [

            {
              label: 'label_replenish_pick', auth: 'wms_overseas_replenish_pick',
              disabled: (row) => row.status != 'EXCEPTION',
              click: (row) => this.replenishPickTask(row)
            },
            {
              label: 'label_replenish_pick_by_face_order', auth: 'wms_overseas_replenish_pick',
              // disabled: (row) => row.status != 'EXCEPTION',
              click: (row) => this.replenishPickTaskByFaceOrder(row)
            },
          ]
        }
      ]
    },
    exportExcel() {
      business_function.confirmOperateBaseSelectOrForm.call(this, {
        data: this.$refs.SuperTablePage.getSearchData(),
        model: this.option.search.model,
        callback: (selection, data) => {
          this.$functionCommon({
            system: "wms",
            url: "/wms-api/outbound/OutboundPickingTruckWallRecordRpc/exportOrderDetailExcel.json",
            data,
          })
        }
      })

    },
    replenishPickTask(row) {
      this.$confirm(this.$tt('tip_confirm_is_replenish_pick'), this.$tt('label_tip'), {
        type: 'warning'
      }).then(({ value }) => {
        this.$ajax({
          url: "/wms-api/outbound/OutboundPickingTruckWallRecordRpc/resetPickTask.json",
          method: 'post', loading: true,
          data: {
            twicePickingId: row.id,
          },
          success: (res) => {
            this.$message.success(this.$tt('tip_submit_success'))
            this.reload()
          }
        })
      }).catch(() => {
      });

    },
    replenishPickTaskByFaceOrder(row) {
      this.$confirm(this.$tt('tip_confirm_is_replenish_pick'), this.$tt('label_tip'), {
        type: 'warning'
      }).then(({ value }) => {
        this.$ajax({
          url: "/wms-api/outbound/OutboundPickingTruckWallRecordRpc/resetPickTaskByWaybill.json",
          method: 'post', loading: true,
          data: {
            twicePickingId: row.id,
          },
          success: (res) => {
            this.$message.success(this.$tt('tip_submit_success'))
            this.reload()
          }
        })
      }).catch(() => {
      });

    },
  }
};

</script>
<style></style>
